import React, {useEffect, useState} from 'react'
import type {ColumnsType} from 'antd/es/table'
import {
	Button,
	Form,
	Row,
	Col,
	Input,
	Select,
	DatePicker,
	Cascader,
	Table,
	InputNumber,
	message,
	Drawer,
	Space,
} from 'antd'
import {PlusOutlined} from '@ant-design/icons'
import moment from 'moment'
import type {UploadFile} from 'antd/es/upload/interface'
import styles from './index.less'
import {getSupplierType} from '@/utils/common'
import {getAllCitys, getGenerateNumber} from '@/service/common'
import {supplierFormData} from './data'
import CustomUpload from '@/components/Upload'
import OtherUpload from './OtherUpload'
import {getPublicDownloadUrl} from '@/service/common/upload'

const {Option} = Select
const {TextArea} = Input
interface DataType {
	subAccount: number
	imgHref: string | undefined
	headquarters: any
	automobileBusinessTime: any
	otherDocumentsUrl3: any
	otherDocumentsUrl2: any
	otherDocumentsUrl1: any
	openingPermitUrl: any
	businessLicenseUrl: any
	fileList: any[]
	tenderSubmitTime: string
	supplierName: string
	supplierType: string
	contacts: string
	bidderPhone: string
	status: string
	bidSection: string
	submissionTime: string
	biddingFileUrl: string
	establishDate: string
	provinceId: string | number
	cityId: string | number
}

type propsType = {
	type: string | undefined
	dictData: any
	answerData: any[]
	setAnswerData: React.Dispatch<React.SetStateAction<any[]>>
}

// 城市
const cityNames = {
	label: 'name',
	value: 'id',
	children: 'cityInfoList',
}

const answer = (props: propsType) => {
	const {type, dictData, answerData, setAnswerData} = props
	const [isModalOpen, setIsModalOpen] = useState(false)
	const [form] = Form.useForm()
	const [status, setStatus] = useState('')
	// 供应商类型列表
	const [supplierTypeData, setSupplierTypeData] =
		useState<supplierAPI.supplierType>([])
	// 城市数据
	const [citysList, setCitysList] = useState([])
	const [supplierType, setSupplierType] = useState<(string | number)[]>([])
	const [urlData, setUrlData] = useState<any>({})
	const [fileList, setFileList] = useState<UploadFile[]>([])
	const [enclosureList, setEnclosureList] = useState<any[]>([])
	const [biddingFileName, setBiddingFileName] = useState<string>('')
	/** 获取城市列表 */
	const getCitysFun = () => {
		getAllCitys().then((res: any) => {
			if (res?.data) {
				setCitysList(() => res.data)
			}
		})
	}
	useEffect(() => {
		if (enclosureList) {
			const arr: any = []
			enclosureList?.forEach(
				(item: {
					targetAttr: number
					id: any
					filename: any
					url: any
				}) => {
					const newData = {
						uid: item?.id,
						name: item?.filename,
						url: item?.url,
					}
					if (item?.targetAttr === 17) {
						arr.push(newData)
					}
				},
			)
			setFileList(arr)
		}
	}, [enclosureList])
	useEffect(() => {
		if (isModalOpen) {
			setFileList([])
			setUrlData({})
		}
	}, [isModalOpen])

	useEffect(() => {
		getCitysFun()
		// 组装供应商类型
		const newData = getSupplierType([
			dictData?.ZC_GYS,
			dictData?.JC_GYS,
			dictData?.CZ_GYS,
			dictData?.SP_GYS,
			dictData?.DYY_GYS,
			dictData?.CS_GYS,
		])
		setSupplierTypeData(newData)
	}, [dictData])
	const columns: ColumnsType<DataType> = [
		{
			title: '投标供应商',
			dataIndex: 'supplierName',
			align: 'center',
			render: (text, record) => (
				<Button
					type="link"
					onClick={() => {
						setStatus('view')
						setIsModalOpen(true)
						setSupplierType(record.supplierType.split(','))
						const urlDatas: any = {
							biddingFileUrl: record?.biddingFileUrl,
							businessLicenseUrl: record?.businessLicenseUrl,
							openingPermitUrl: record?.openingPermitUrl,
							otherDocumentsUrl1: record?.otherDocumentsUrl1,
							otherDocumentsUrl2: record?.otherDocumentsUrl2,
							otherDocumentsUrl3: record?.otherDocumentsUrl3,
						}
						setUrlData(urlDatas)
						const url = [
							record?.biddingFileUrl,
							record?.businessLicenseUrl,
							record?.openingPermitUrl,
							record?.otherDocumentsUrl1,
							record?.otherDocumentsUrl2,
							record?.otherDocumentsUrl3,
						]
						getPublicDownloadUrl(
							url?.map(Number)?.filter((item) => item !== 0),
						)
							.then((result: any) => {
								setEnclosureList(result?.data)
							})
							.catch((err: any) => {
								message.error(err)
							})
						form.setFieldsValue({
							...record,
							city: record?.cityId
								? [record?.provinceId, record?.cityId]
								: '',
							supplierType: record.supplierType.split(','),
							establishDate: record?.establishDate
								? moment(record.establishDate)
								: '',
							automobileBusinessTime:
								record?.automobileBusinessTime
									? moment(record?.automobileBusinessTime)
									: '',
							headquarters: record?.headquarters
								?.split(',')
								?.map(Number),
							tenderSubmitTime: record?.tenderSubmitTime
								? moment(record.tenderSubmitTime)
								: '',
							subAccount:
								record?.subAccount === 0
									? undefined
									: record?.subAccount,
						})
					}}>
					{text}
				</Button>
			),
		},
		{
			title: '供应商类型',
			dataIndex: 'supplierType',
			align: 'center',
			render: (text) => (
				<Cascader
					disabled
					value={text.split(',')}
					options={supplierTypeData}
				/>
			),
		},
		{
			title: '投标联系人',
			dataIndex: 'bidderPerson',
			align: 'center',
		},
		{
			title: '联系电话',
			dataIndex: 'bidderPhone',
			align: 'center',
		},
		{
			title: '投标状态',
			dataIndex: 'bidStatus',
			align: 'center',
			render: () => '已投标',
		},
		{
			title: '投标标段',
			dataIndex: 'bidSection',
			align: 'center',
			render: (text) => (
				<Select
					value={text}
					disabled
					fieldNames={{value: 'dictKey', label: 'dictValue'}}
					options={dictData?.Project_Bid_Section}
				/>
			),
		},
		{
			title: '标书递交时间',
			dataIndex: 'tenderSubmitTime',
			align: 'center',
		},
		{
			title: '投标文件',
			dataIndex: 'biddingFileName',
			align: 'center',
			render: (text, record) => (
				<a href={record?.imgHref} download>
					{text}
				</a>
			),
		},
	]
	const onCancel = () => {
		form.resetFields()
		setIsModalOpen(false)
	}

	const submit = async () => {
		const newData = [...answerData]
		const value = await form.validateFields()
		const data = newData.find(
			(item) => item?.socialCreditCode === value?.socialCreditCode,
		)
		if (value) {
			if (data) {
				message.warning('统一社会信用代码与已有记录重复')
			} else {
				const datas = {
					...supplierFormData,
					...value,
					...urlData,
					biddingFileName,
					supplierType: value?.supplierType.toString(),
					provinceId: value?.city?.[0],
					cityId: value?.city?.[1],
					automobileBusinessTime: value?.automobileBusinessTime
						? moment(value?.automobileBusinessTime).format(
								'YYYY-MM-DD',
						  )
						: '',
					headquarters: value?.headquarters?.toString(),
					establishDate: value?.establishDate
						? moment(value?.establishDate).format('YYYY-MM-DD')
						: '',
					tenderSubmitTime: moment(value?.tenderSubmitTime).format(
						'YYYY-MM-DD HH:mm',
					),
				}
				if (!urlData?.businessLicenseUrl) {
					message.warning('请上传营业执照')
				} else if (!urlData?.openingPermitUrl) {
					message.warning('请上传开户许可证')
				} else if (!urlData?.biddingFileUrl) {
					message.warning('请上传投标文件')
				}
				if (
					urlData?.businessLicenseUrl &&
					urlData?.openingPermitUrl &&
					urlData?.biddingFileUrl
				) {
					getPublicDownloadUrl([Number(urlData?.biddingFileUrl)])
						.then((res: any) => {
							if (res?.success) {
								datas.imgHref = res?.data?.[0]?.url
								newData.push(datas)
								setAnswerData(newData)
								form.resetFields()
								setIsModalOpen(false)
							}
						})
						.catch((err: any) => {
							message.error(err)
						})
				}
			}
		}
	}

	const callBack = (value: string | number, key: any) => {
		const data = {...urlData}
		data[value] = key
		setUrlData(data)
	}

	const uploadDom = (targetAttr: number, name: string) => {
		const uploadProps: any = {
			key: targetAttr,
			modelName: 'spBidding',
			targetAttr,
			all: true,
			callback: (key: any) => {
				if (key?.targetAttr === 16) {
					setBiddingFileName(key?.filename)
				}
				callBack(name, key?.id)
			},
		}
		if (status === 'view') {
			const newData = enclosureList?.find(
				(item: {targetAttr: number}) => item?.targetAttr === targetAttr,
			)
			if (newData) {
				uploadProps.fileList = [
					{
						uid: newData?.targetAttr?.toString(),
						name: newData?.filename,
						url: newData?.url,
					},
				]
			}
		}
		return (
			<>
				{' '}
				<CustomUpload {...uploadProps} />{' '}
			</>
		)
	}

	return (
		<div>
			<div className={styles.btnlist}>
				{type !== 'view' ? (
					<Button
						icon={<PlusOutlined />}
						type="primary"
						ghost
						size="small"
						onClick={() => {
							setStatus('add')
							setIsModalOpen(true)
							getGenerateNumber('ZBYD').then((res: any) => {
								form.setFieldsValue({supplierCode: res.data})
							})
						}}>
						新增应答
					</Button>
				) : (
					''
				)}
			</div>
			<Table
				columns={columns}
				dataSource={answerData}
				pagination={false}
				loading={false}
			/>
			<Drawer
				title={status === 'view' ? '应答供应商' : '新增应答供应商'}
				placement="right"
				width={720}
				onClose={onCancel}
				open={isModalOpen}
				destroyOnClose
				extra={
					<Space>
						{status === 'view' ? null : (
							<>
								<Button size="small" onClick={onCancel}>
									取消
								</Button>
								<Button
									type="primary"
									size="small"
									onClick={submit}>
									确定
								</Button>
							</>
						)}
					</Space>
				}>
				<Form
					form={form}
					name="basic"
					layout="horizontal"
					labelCol={{flex: '140px'}}
					labelAlign="right"
					labelWrap
					autoComplete="off"
					disabled={status === 'view'}>
					<Form.Item label="供应商编号" name="supplierCode" hidden>
						<Input placeholder={type === 'view' ? '-' : '请输入'} />
					</Form.Item>
					<Row gutter={12}>
						<Col span={12}>
							<Form.Item
								label="供应商类型"
								name="supplierType"
								rules={[{required: true}]}
								colon>
								<Cascader
									onChange={(value) => {
										setSupplierType(value)
										if (value?.[0] === 'SP_GYS') {
											form.setFieldsValue({
												channelType: '2',
											})
										}
									}}
									options={supplierTypeData}
									placeholder={
										type === 'view' ? '-' : '请选择'
									}
								/>
							</Form.Item>
						</Col>
						<Col span={12}>
							<Form.Item
								label="统一社会信用代码"
								name="socialCreditCode"
								rules={[
									{
										required: true,
										message: '请输入统一社会信用代码',
									},
									{
										pattern:
											/^[^_IOZSVa-z\W]{2}\d{6}[^_IOZSVa-z\W]{10}$/g,
										message: '请输入正确的统一社会信用代码',
									},
								]}>
								<Input
									placeholder={
										type === 'view' ? '-' : '请输入'
									}
								/>
							</Form.Item>
						</Col>
						<Col span={12}>
							<Form.Item
								label="供应商名称"
								name="supplierName"
								rules={[
									{
										required: true,
										max: 20,
									},
								]}>
								<Input
									placeholder={
										type === 'view' ? '-' : '请输入'
									}
								/>
							</Form.Item>
						</Col>

						{supplierType[0] === 'SP_GYS' ||
						supplierType[0] === 'CS_GYS' ? (
							''
						) : (
							<Col span={12}>
								<Form.Item
									label="供应商简称"
									name="abbreviation"
									rules={[{required: true, max: 10}]}>
									<Input
										placeholder={
											type === 'view' ? '-' : '请输入'
										}
									/>
								</Form.Item>
							</Col>
						)}

						{supplierType[0] === 'DYY_GYS' ? (
							<>
								<Col span={12}>
									<Form.Item
										label="企业法人"
										name="legalPerson">
										<Input
											placeholder={
												type === 'view' ? '-' : '请输入'
											}
										/>
									</Form.Item>
								</Col>
								<Col span={12}>
									<Form.Item
										label="是否代持"
										name="isHolding">
										<Select
											placeholder={
												type === 'view' ? '-' : '请选择'
											}
											allowClear>
											<Option value={1}>是</Option>
											<Option value={2}>否</Option>
										</Select>
									</Form.Item>
								</Col>
								<Col span={12}>
									<Form.Item
										label="实际控制人"
										name="actualController">
										<Input
											placeholder={
												type === 'view' ? '-' : '请输入'
											}
										/>
									</Form.Item>
								</Col>
								<Col span={12}>
									<Form.Item
										label="注册地址"
										name="registeredAddress">
										<Input
											placeholder={
												type === 'view' ? '-' : '请输入'
											}
										/>
									</Form.Item>
								</Col>
								<Col span={12}>
									<Form.Item
										label="实际办公地址"
										name="actualOfficeAddress">
										<Input
											placeholder={
												type === 'view' ? '-' : '请输入'
											}
										/>
									</Form.Item>
								</Col>
								<Col span={12}>
									<Form.Item
										label="固定电话"
										name="telephone"
										rules={[
											{
												pattern:
													/^(((\d{3,4})?[0-9]{7,8})|(1(3|4|5|6|7|8|9)\d{9}))$/,
												message: '填写的电话格式有误',
											},
										]}>
										<Input
											placeholder={
												type === 'view' ? '-' : '请输入'
											}
										/>
									</Form.Item>
								</Col>
								<Col span={12}>
									<Form.Item
										label="注册资本/元"
										name="registeredCapital"
										rules={[
											{
												pattern:
													/^([0-9]|[1-9]\d+)(\.\d{0,2})?$/,
												message: '小数点后不得超过两位',
											},
										]}>
										<InputNumber
											max={1000000000}
											placeholder={
												type === 'view' ? '-' : '请输入'
											}
										/>
									</Form.Item>
								</Col>
								<Col span={12}>
									<Form.Item
										label="实缴资本/元"
										name="actualCapital"
										rules={[
											{
												pattern:
													/^([0-9]|[1-9]\d+)(\.\d{0,2})?$/,
												message: '小数点后不得超过两位',
											},
										]}>
										<InputNumber
											max={1000000000}
											placeholder={
												type === 'view' ? '-' : '请输入'
											}
										/>
									</Form.Item>
								</Col>
								<Col span={12}>
									<Form.Item
										label="业务模式"
										name="businessModel">
										<Select
											placeholder={
												type === 'view' ? '-' : '请选择'
											}
											allowClear
											fieldNames={{
												value: 'dictKey',
												label: 'dictValue',
											}}
											options={
												dictData?.Business_Situation
											}
										/>
									</Form.Item>
								</Col>
							</>
						) : (
							''
						)}
						{supplierType[0] === 'SP_GYS' ? (
							<>
								<Col span={12}>
									<Form.Item
										label="企业法人"
										name="legalPerson">
										<Input
											placeholder={
												type === 'view' ? '-' : '请输入'
											}
										/>
									</Form.Item>
								</Col>
								<Col span={12}>
									<Form.Item
										label="渠道负责人"
										name="channelLeader">
										<Input
											placeholder={
												type === 'view' ? '-' : '请输入'
											}
										/>
									</Form.Item>
								</Col>
								<Col span={12}>
									<Form.Item
										label="负责人电话"
										name="leadingPhone"
										rules={[
											{
												pattern:
													/^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/,
												message: '请输入正确的手机号',
											},
										]}>
										<Input
											placeholder={
												type === 'view' ? '-' : '请输入'
											}
										/>
									</Form.Item>
								</Col>
								<Col span={12}>
									<Form.Item
										label="常用地址"
										name="address"
										rules={[{max: 30}]}>
										<Input
											placeholder={
												type === 'view' ? '-' : '请输入'
											}
										/>
									</Form.Item>
								</Col>
								{/* <Col span={12}>
									<Form.Item
										label="固定电话"
										name="linePhone"
										rules={[
											{
												pattern:
													/^(((\d{3,4})?[0-9]{7,8})|(1(3|4|5|6|7|8|9)\d{9}))$/,
												message: '填写的电话格式有误',
											},
										]}>
										<Input
											placeholder={
												type === 'view' ? '-' : '请输入'
											}
										/>
									</Form.Item>
								</Col> */}
								<Col span={12}>
									<Form.Item
										label="代理业务"
										name="agencyService">
										<Select
											placeholder={
												type === 'view' ? '-' : '请选择'
											}
											allowClear
											fieldNames={{
												value: 'dictKey',
												label: 'dictValue',
											}}
											options={dictData?.Agency_Business}
										/>
									</Form.Item>
								</Col>
								<Col span={12}>
									<Form.Item
										label="合作模式"
										name="cooperationMode">
										<Select
											placeholder={
												type === 'view' ? '-' : '请选择'
											}
											allowClear
											fieldNames={{
												value: 'dictKey',
												label: 'dictValue',
											}}
											options={dictData?.Cooperation_Mode}
										/>
									</Form.Item>
								</Col>
								{/* <Col span={12}>
									<Form.Item
										label="业务模式"
										name="businessModel">
										<Select
											placeholder={
												type === 'view' ? '-' : '请选择'
											}
											allowClear
											fieldNames={{
												value: 'dictKey',
												label: 'dictValue',
											}}
											options={dictData?.Business_Model}
										/>
									</Form.Item>
								</Col>
								<Col span={12}>
									<Form.Item
										label="公司类型"
										name="companyType">
										<Select
											placeholder={
												type === 'view' ? '-' : '请选择'
											}
											allowClear
											fieldNames={{
												value: 'dictKey',
												label: 'dictValue',
											}}
											options={dictData?.Company_Type}
										/>
									</Form.Item>
								</Col> */}
								<Col span={12}>
									<Form.Item
										label="渠道类型"
										name="channelType">
										<Select
											placeholder={
												type === 'view' ? '-' : '请选择'
											}
											fieldNames={{
												value: 'dictKey',
												label: 'dictValue',
											}}
											disabled
											options={dictData?.Channel_Type}
										/>
									</Form.Item>
								</Col>
								<Col span={12}>
									<Form.Item
										label="渠道标签"
										name="channelLabel">
										<Input
											placeholder={
												type === 'view' ? '-' : '请输入'
											}
										/>
									</Form.Item>
								</Col>
								<Col span={12}>
									<Form.Item
										label="结算周期"
										name="settlementCycle">
										<Select
											placeholder={
												type === 'view' ? '-' : '请选择'
											}
											allowClear
											fieldNames={{
												value: 'dictKey',
												label: 'dictValue',
											}}
											options={dictData?.Settlement_Cycle}
										/>
									</Form.Item>
								</Col>
								<Col span={12}>
									<Form.Item label="税率" name="taxRate">
										<Select
											placeholder={
												type === 'view' ? '-' : '请选择'
											}
											allowClear
											fieldNames={{
												value: 'dictKey',
												label: 'dictValue',
											}}
											options={
												dictData?.Invoicing_Tax_Rate
											}
										/>
									</Form.Item>
								</Col>
								{/* <Col span={12}>
									<Form.Item
										label="是否有子账户"
										name="subAccount">
										<Select
											placeholder={
												type === 'view' ? '-' : '请选择'
											}
											allowClear
											onSelect={(value: number) =>
												setSubAccountType(value)
											}>
											<Option value={1}>是</Option>
											<Option value={2}>否</Option>
										</Select>
									</Form.Item>
								</Col>
								{subAccountType === 1 ? (
									<Col span={12}>
										<Form.Item
											label="开设子账户的条件"
											name="accountConditions">
											<Input
												placeholder={
													type === 'view'
														? '-'
														: '请输入'
												}
											/>
										</Form.Item>
									</Col>
								) : (
									''
								)} */}
								<Col span={12}>
									<Form.Item
										label="结算方式"
										name="settlementMethod"
										rules={[{required: true}]}>
										<Select
											placeholder={
												type === 'view' ? '-' : '请选择'
											}
											allowClear
											fieldNames={{
												value: 'dictKey',
												label: 'dictValue',
											}}
											options={
												dictData?.SP_Settlement_Method
											}
										/>
									</Form.Item>
								</Col>
								<Col span={12}>
									<Form.Item
										label="保证金金额"
										name="earnestMoney"
										rules={[
											{required: true},
											{
												pattern:
													/^([0-9]|[1-9]\d+)(\.\d{0,2})?$/,
												message: '小数点后不得超过两位',
											},
										]}>
										<InputNumber
											formatter={(value) => {
												if (type === 'view') {
													return `${value}元`
												}
												return value?.toString() || ''
											}}
											max={1000000000}
											addonAfter="元"
											placeholder={
												type === 'view' ? '-' : '请输入'
											}
										/>
									</Form.Item>
								</Col>
							</>
						) : (
							''
						)}
						{supplierType[0] === 'CZ_GYS' &&
						supplierType[1] === '32' ? (
							<>
								<Col span={12}>
									<Form.Item
										label="企业性质"
										name="enterpriseNature">
										<Select
											placeholder={
												type === 'view' ? '-' : '请选择'
											}
											allowClear
											fieldNames={{
												value: 'dictKey',
												label: 'dictValue',
											}}
											options={
												dictData?.Enterprise_Nature
											}
										/>
									</Form.Item>
								</Col>
								<Col span={12}>
									<Form.Item label="注册城市" name="city">
										<Cascader
											fieldNames={{
												label: 'name',
												value: 'id',
												children: 'cityInfoList',
											}}
											options={citysList}
											placeholder={
												type === 'view' ? '-' : '请选择'
											}
										/>
									</Form.Item>
								</Col>
								<Col span={12}>
									<Form.Item
										label="成立日期"
										name="establishDate">
										<DatePicker
											placeholder={
												type === 'view' ? '-' : '请选择'
											}
										/>
									</Form.Item>
								</Col>
								<Col span={12}>
									<Form.Item
										label="从事汽车，二手车业务时间"
										name="automobileBusinessTime">
										<DatePicker
											placeholder={
												type === 'view' ? '-' : '请选择'
											}
										/>
									</Form.Item>
								</Col>
								<Col span={12}>
									<Form.Item
										label="近一年月均二手车交易量"
										name="carTransactionVolume">
										<InputNumber
											formatter={(value) => {
												if (type === 'view') {
													return `${value}台/月`
												}
												return value?.toString() || ''
											}}
											addonAfter="台/月"
											placeholder={
												type === 'view' ? '-' : '请输入'
											}
										/>
									</Form.Item>
								</Col>
								<Col span={12}>
									<Form.Item
										label="总部/区域"
										name="headquarters">
										<Cascader
											fieldNames={{
												label: 'name',
												value: 'id',
												children: 'cityInfoList',
											}}
											options={citysList}
											placeholder={
												type === 'view' ? '-' : '请选择'
											}
										/>
									</Form.Item>
								</Col>
								<Col span={12}>
									<Form.Item label="品类" name="category">
										<Select
											placeholder={
												type === 'view' ? '-' : '请选择'
											}
											allowClear
											fieldNames={{
												value: 'dictKey',
												label: 'dictValue',
											}}
											options={dictData?.Category}
										/>
									</Form.Item>
								</Col>
								<Col span={12}>
									<Form.Item
										label="开票税率"
										name="invoicingRate">
										<Select
											placeholder={
												type === 'view' ? '-' : '请选择'
											}
											allowClear
											fieldNames={{
												value: 'dictKey',
												label: 'dictValue',
											}}
											options={
												dictData?.Invoicing_Tax_Rate
											}
										/>
									</Form.Item>
								</Col>
								<Col span={12}>
									<Form.Item
										label="联系人"
										name="contacts"
										rules={[{max: 6}]}>
										<Input
											placeholder={
												type === 'view' ? '-' : '请输入'
											}
										/>
									</Form.Item>
								</Col>
								<Col span={12}>
									<Form.Item
										label="联系人手机"
										name="mobilePhone"
										rules={[
											{
												pattern:
													/^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/,
												message: '请输入正确的手机号',
											},
										]}>
										<Input
											placeholder={
												type === 'view' ? '-' : '请输入'
											}
										/>
									</Form.Item>
								</Col>
								<Col span={12}>
									<Form.Item
										label="联系人邮箱"
										name="email"
										rules={[
											{
												type: 'email',
												message: '填写的邮箱格式有误',
											},
										]}>
										<Input
											placeholder={
												type === 'view' ? '-' : '请输入'
											}
										/>
									</Form.Item>
								</Col>
								<Col span={12}>
									<Form.Item
										label="常用地址"
										name="address"
										rules={[{max: 30}]}>
										<Input
											placeholder={
												type === 'view' ? '-' : '请输入'
											}
										/>
									</Form.Item>
								</Col>
								<Col span={12}>
									<Form.Item
										label="邮编"
										name="postalCode"
										rules={[
											{
												pattern: /^[0-9]\d{5}$/,
												message: '请输入正确的邮编',
											},
										]}>
										<Input
											placeholder={
												type === 'view' ? '-' : '请输入'
											}
										/>
									</Form.Item>
								</Col>
								<Col span={12}>
									<Form.Item
										label="公司和法人是否有违法违规记录"
										name="isIllegal">
										<Select
											placeholder={
												type === 'view' ? '-' : '请选择'
											}
											allowClear>
											<Option value={1}>是</Option>
											<Option value={2}>否</Option>
										</Select>
									</Form.Item>
								</Col>
								<Col span={12}>
									<Form.Item
										label="公司目前是否有债务财务纠纷"
										name="isFinancialEmbroilment">
										<Select
											placeholder={
												type === 'view' ? '-' : '请选择'
											}
											allowClear>
											<Option value={1}>是</Option>
											<Option value={2}>否</Option>
										</Select>
									</Form.Item>
								</Col>
								<Col span={24}>
									<Form.Item
										label="公司服务的主要企业或参与的重要项目"
										name="enterpriseProject">
										<TextArea
											maxLength={200}
											placeholder="请输入（最多200个字）"
											autoSize={{minRows: 3, maxRows: 6}}
										/>
									</Form.Item>
								</Col>
								<Col span={24}>
									<Form.Item
										label="公司侧重/倾向于哪些车型的处置业务？"
										name="handleBusiness">
										<TextArea
											maxLength={200}
											placeholder="请输入（最多200个字）"
											autoSize={{minRows: 3, maxRows: 6}}
										/>
									</Form.Item>
								</Col>
							</>
						) : (
							''
						)}
						{supplierType[0] === 'DYY_GYS' ||
						supplierType[0] === 'SP_GYS' ||
						(supplierType[0] === 'CZ_GYS' &&
							supplierType?.[1] === '32') ? (
							''
						) : (
							<>
								<Col span={12}>
									<Form.Item
										label="企业性质"
										name="enterpriseNature">
										<Select
											placeholder={
												type === 'view' ? '-' : '请选择'
											}
											allowClear
											fieldNames={{
												value: 'dictKey',
												label: 'dictValue',
											}}
											options={
												dictData?.Enterprise_Nature
											}
										/>
									</Form.Item>
								</Col>
								{supplierType[0] === 'CS_GYS' ? (
									''
								) : (
									<Col span={12}>
										<Form.Item label="注册城市" name="city">
											<Cascader
												fieldNames={cityNames}
												options={citysList}
												placeholder={
													type === 'view'
														? '-'
														: '请选择'
												}
											/>
										</Form.Item>
									</Col>
								)}
								<Col span={12}>
									<Form.Item
										label="常用地址"
										name="address"
										rules={[{max: 30}]}>
										<Input
											placeholder={
												type === 'view' ? '-' : '请输入'
											}
										/>
									</Form.Item>
								</Col>
								<Col span={12}>
									<Form.Item
										label="付款条件"
										name="payCondition">
										<Select
											placeholder={
												type === 'view' ? '-' : '请选择'
											}
											allowClear
											fieldNames={{
												value: 'dictKey',
												label: 'dictValue',
											}}
											options={dictData?.Term_Payment}
										/>
									</Form.Item>
								</Col>
								<Col span={12}>
									<Form.Item
										label="开票税率"
										name="invoicingRate">
										<Select
											placeholder={
												type === 'view' ? '-' : '请选择'
											}
											allowClear
											fieldNames={{
												value: 'dictKey',
												label: 'dictValue',
											}}
											options={
												dictData?.Invoicing_Tax_Rate
											}
										/>
									</Form.Item>
								</Col>
								<Col span={12}>
									<Form.Item
										label="联系人"
										name="contacts"
										rules={[{max: 6}]}>
										<Input
											placeholder={
												type === 'view' ? '-' : '请输入'
											}
										/>
									</Form.Item>
								</Col>
								<Col span={12}>
									<Form.Item
										label="联系人手机"
										name="mobilePhone"
										rules={[
											{
												pattern:
													/^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/,
												message: '请输入正确的手机号',
											},
										]}>
										<Input
											placeholder={
												type === 'view' ? '-' : '请输入'
											}
										/>
									</Form.Item>
								</Col>
								<Col span={12}>
									<Form.Item
										label="联系人邮箱"
										name="email"
										rules={[
											{
												type: 'email',
												message: '填写的邮箱格式有误',
											},
										]}>
										<Input
											placeholder={
												type === 'view' ? '-' : '请输入'
											}
										/>
									</Form.Item>
								</Col>
								{supplierType[0] === 'CS_GYS' ? (
									''
								) : (
									<Col span={12}>
										<Form.Item
											label="固定电话"
											name="telephone"
											rules={[
												{
													pattern:
														/^(((\d{3,4})?[0-9]{7,8})|(1(3|4|5|6|7|8|9)\d{9}))$/,
													message:
														'填写的电话格式有误',
												},
											]}>
											<Input
												placeholder={
													type === 'view'
														? '-'
														: '请输入'
												}
											/>
										</Form.Item>
									</Col>
								)}

								<Col span={12}>
									<Form.Item
										label="注册资本"
										name="registeredCapital"
										rules={[
											{
												pattern:
													/^([0-9]|[1-9]\d+)(\.\d{0,2})?$/,
												message: '小数点后不得超过两位',
											},
										]}>
										<InputNumber
											formatter={(value) => {
												if (type === 'view') {
													return `${value}元`
												}
												return value?.toString() || ''
											}}
											max={1000000000}
											addonAfter="元"
											placeholder={
												type === 'view' ? '-' : '请输入'
											}
										/>
									</Form.Item>
								</Col>
								<Col span={12}>
									<Form.Item
										label="成立日期"
										name="establishDate">
										<DatePicker
											placeholder={
												type === 'view' ? '-' : '请选择'
											}
										/>
									</Form.Item>
								</Col>
								<Col span={12}>
									<Form.Item
										label="邮编"
										name="postalCode"
										rules={[
											{
												pattern: /^[0-9]\d{5}$/,
												message: '请输入正确的邮编',
											},
										]}>
										<Input
											placeholder={
												type === 'view' ? '-' : '请输入'
											}
										/>
									</Form.Item>
								</Col>
								{supplierType[0] === 'CS_GYS' ? (
									<>
										{' '}
										<Col span={12}>
											<Form.Item
												label="结算方式"
												name="settlementMethod">
												<Select
													placeholder={
														type === 'view'
															? '-'
															: '请选择'
													}
													allowClear
													fieldNames={{
														value: 'dictKey',
														label: 'dictValue',
													}}
													options={
														dictData?.CS_Settlement_Method
													}
												/>
											</Form.Item>
										</Col>
										<Col span={12}>
											<Form.Item
												label="保证金金额"
												name="earnestMoney"
												rules={[
													{
														pattern:
															/^([0-9]|[1-9]\d+)(\.\d{0,2})?$/,
														message:
															'小数点后不得超过两位',
													},
												]}>
												<InputNumber
													formatter={(value) => {
														if (type === 'view') {
															return `${value}元`
														}
														return (
															value?.toString() ||
															''
														)
													}}
													max={1000000000}
													addonAfter="元"
													placeholder={
														type === 'view'
															? '-'
															: '请输入'
													}
												/>
											</Form.Item>
										</Col>
									</>
								) : (
									''
								)}

								<Col span={24}>
									<Form.Item
										label="公司简介"
										name="companyIntroduction">
										<TextArea
											maxLength={200}
											placeholder="请输入（最多200个字）"
											autoSize={{minRows: 3, maxRows: 6}}
										/>
									</Form.Item>
								</Col>
							</>
						)}
						<Col span={12}>
							<Form.Item
								label="投标人"
								name="bidderPerson"
								rules={[
									{
										required: true,
										max: 6,
									},
								]}>
								<Input
									placeholder={
										type === 'view' ? '-' : '请输入'
									}
								/>
							</Form.Item>
						</Col>
						<Col span={12}>
							<Form.Item
								label="联系电话"
								name="bidderPhone"
								rules={[
									{required: true},
									{
										pattern:
											/^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/,
										message: '请输入正确的联系电话',
									},
								]}>
								<Input
									placeholder={
										type === 'view' ? '-' : '请输入'
									}
								/>
							</Form.Item>
						</Col>
						<Col span={12}>
							<Form.Item
								label="投标标段"
								name="bidSection"
								rules={[
									{
										required: true,
									},
								]}>
								<Select
									placeholder={
										type === 'view' ? '-' : '请选择'
									}
									allowClear
									fieldNames={{
										value: 'dictKey',
										label: 'dictValue',
									}}
									options={dictData?.Project_Bid_Section}
								/>
							</Form.Item>
						</Col>
						<Col span={12}>
							<Form.Item
								label="标书递交时间"
								name="tenderSubmitTime"
								rules={[
									{
										required: true,
									},
								]}>
								<DatePicker
									placeholder={
										type === 'view' ? '-' : '请选择'
									}
									showTime
									format="YYYY-MM-DD HH:mm"
								/>
							</Form.Item>
						</Col>
					</Row>
					<table border="1" className={styles.uploadWrap}>
						<tr>
							<td className={styles.required}>营业执照</td>
							<td>{uploadDom(14, 'businessLicenseUrl')}</td>
							<td className={styles.required}>开户许可证</td>
							<td>{uploadDom(15, 'openingPermitUrl')}</td>
						</tr>
						<tr>
							<td className={styles.required}>投标文件</td>
							<td>{uploadDom(16, 'biddingFileUrl')}</td>
							<td />
							<td />
						</tr>
						<tr>
							<td colSpan={4}>
								<OtherUpload
									uploadType="DDUpload"
									urlName="otherDocumentsUrl"
									targetAttr={17}
									fileList={fileList}
									setFileList={setFileList}
									enclosureList={enclosureList}
									urlData={urlData}
									setUrlData={setUrlData}
								/>
							</td>
						</tr>
					</table>
				</Form>
			</Drawer>
		</div>
	)
}

export default answer
